<template>
  <view class="member-group-tab" :style="[sectionStyle]" v-if="showMemberCard">
    <view class="group-tab-content" :style="[sectionBorderRadius]">
      <view
        class="group-item"
        :class="[
          index + 1 == memberTabGroup.length ? 'no-affter' : '',
          memberTabNum == 2 ? 'two-node' : '',
          memberTabNum == 1 ? 'one-node' : ''
        ]"
        v-for="(item, index) in memberTabGroup"
        :key="index"
      >
        <view class="group-box" @click="handleItem(item)">
          <view class="group-item-title">
            <image
              :src="
                item.picImg ||
                'https://chidian.chixiaodian.com/web/uploads/images/store_1/2021-10-21/b81e3fdcdd8306e4b3ea6dae70412fd6d21922e4.png'
              "
            />
            <view :style="{ color: item.titleColor }">{{ item.title }}</view>
          </view>
          <view class="subtitle">
            <view :style="{ color: item.subtitleColor }">{{
              item.subtitle
            }}</view>
            <i
              :style="{ color: item.subtitleColor }"
              class="iconfont icon-arrow-right"
            ></i>
          </view>
        </view>
      </view>

      <view class="member-group-bg" :style="[memberGroupBg]"></view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    propsData: {
      type: Object,
      default: {}
    }
  },
  components: {},
  data() {
    return {};
  },
  mounted() {},
  watch: {},
  computed: {
    showMemberCard() {
      if (this.propsData.params === undefined) {
        return true;
      }
      return this.propsData.params.showMember;
    },
    memberTabGroup() {
      return this.propsData.params.memberTabGroup;
    },
    memberGroupBg() {
      let style = Object.assign({}, this.propsData.params.memberTabCss);
      delete style.padding;
      return style;
    },
    memberTabNum() {
      return this.propsData.params.memberTabNum;
    },
    sectionStyle() {
      let style = this.propsData.params.memberTabCss;
      let obj = {
        margin: `0 ${style.padding * 2}rpx`
      };
      return obj;
    },
    sectionBorderRadius() {
      let style = this.propsData.params.memberTabCss;
      let obj = {
        borderRadius: `${style.borderRadius * 2}rpx`
      };
      return obj;
    }
  },
  methods: {
    handleItem(item) {
      if (Object.keys(item.link).length) {
        this.$utils.diySkip(item.link);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.member-group-tab {
  height: 12.534vw;
  position: relative;
  margin: 0 auto;
  .group-tab-content {
    width: 100%;
    height: 14.67vw;
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 11;
    border-radius: 2.67vw;
    overflow: hidden;
    display: flex;
    align-items: center;
    .group-item {
      width: 33.3%;
      height: 100%;
      display: flex;
      align-items: center;
      padding-left: 3.2vw;
      position: relative;
      .group-box {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        position: relative;
      }

      .group-item-title {
        display: flex;
        align-items: center;
        image {
          width: 3.73vw;
          height: 3.73vw;
          //   background: #303685;
          border-radius: 50%;
          display: block;
          margin-right: 2px;
        }
        view {
          font-size: 3.467vw;
          font-family: PingFang SC;
          font-weight: 600;
          color: #262626;
        }
      }
      .subtitle {
        font-size: 2.93vw;
        font-family: PingFang SC;
        font-weight: 400;
        color: #b4853f;
        margin-bottom: 0;
        margin-top: 0.8vw;
        display: flex;
        align-items: center;
        .iconfont {
          color: #b4853f;
          font-size: 19rpx;
        }
      }
    }
    .group-item::after {
      content: "";
      width: 1px;
      height: 5.34vw;
      background: #efd5b1;
      position: absolute;
      right: 0;
      top: 4.67vw;
    }
    .no-affter::after {
      display: none;
    }
    .member-group-bg {
      width: 100%;
      height: 100%;
      z-index: -1;
      position: absolute;
      left: 0;
      top: 0;
    }
    .two-node {
      width: 50%;
    }
    .one-node {
      width: 100%;
    }
  }
}
</style>
